public class Factorialsum {
    public static void main(String[] args) {
        System.out.println(factsun(3));
    }
    public static int factsun(int n) {
        int sum = 0;
        int a = 1;
        for(int i=1;i<=n;i++){
            a=1;
            for(int k=1;k<=i;k++){
                a=a*k;
            }
            sum=sum+a;
        }
        return sum;
    }

}
